#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n < 100 || n>999)
        return 1;
    int ret = 0;
    int i = 1;
    while (ret != 495)
    {
        int a = n / 100, b = n / 10 % 10, c = n % 10;
        vector<int> num = { a,b,c };
        sort(num.begin(), num.end());
        int num1 = num[2] * 100 + num[1] * 10 + num[0];
        int num2 = num[0] * 100 + num[1] * 10 + num[2];
        ret = num1 - num2;
        n = ret;
        cout << i << ":" << " " << num1 << " " << "-" << " " << num2 << " " << "=" << " " << ret << endl;
        i++;
    }
    return 0;
}